/* eslint-disable no-unused-vars */
// eslint-disable-next-line object-curly-newline
import { ReducersMapObject, AnyAction, Reducer } from 'redux';
// TODO 中间件
import { connectRouter, RouterState } from 'connected-react-router';
import home, { HomeState } from './home';
import mine, { MineState } from './mine';
import profile, { ProfileState } from './profile';
import history from '../history';
import cart from "./cart";
import { combineReducers } from "redux-immer";
import produce from "immer";
// 合并后的根状态
export interface CombinedState {
    home: HomeState,
    mine: MineState,
    profile: ProfileState,
    router: RouterState<any>
}
// 合并后的根reduer
const reducers: ReducersMapObject<CombinedState, AnyAction> = {
    home,
    mine,
    profile,
    router: connectRouter(history),
    cart
};

const reducer: Reducer <CombinedState, AnyAction> = combineReducers<CombinedState>(produce, reducers);

export default reducer;
